// src/api/user.js
export const getUserList = async ({ page = 1, pageSize = 10, username = '' } = {}) => {
  // 模拟总数据
  const mockUsers = Array.from({ length: 100 }, (_, i) => ({
    id: i + 1,
    name: `user${i + 1}`,
  }));

  // 过滤用户名
  const filteredUsers = username ? mockUsers.filter(user => user.name.includes(username)) : mockUsers;

  // 计算分页
  const start = (page - 1) * pageSize;
  const end = start + pageSize;
  const list = filteredUsers.slice(start, end);

  // 模拟异步请求
  return new Promise(resolve => {
    setTimeout(() => {
      resolve({
        list,
        total: filteredUsers.length,
      });
    }, 500); // 模拟 500ms 网络延迟
  });
};
